<template>
    <div>
        <van-tabs v-model="active">
            <van-tab title="修改个人信息">
                <van-field v-model="userName" label="用户名" placeholder="请输入用户名"/>
                <van-field v-model="phonenumber" label="手机号" placeholder="请输入手机号"/>
                <van-field v-model="email" label="邮箱" placeholder="邮箱"/>
                <van-field v-model="remark" label="个人说明" type="email" placeholder="个人说明"/>
                <van-button type="info" style="width: 80%;margin-top: 30px; border-radius: 30px" @click="changeUserInfo">确认修改</van-button>
            </van-tab>
        </van-tabs>


    </div>
</template>

<script>
    import {getusertInfo,changeUserInfo} from "../api/api";

    export default {
        name: "changUser",
        data(){
            return{
                active:0,
                userName:"",
                phonenumber:"",
                email:"",
                remark:""
            }
        },
        methods:{
            changeUserInfo(){
                changeUserInfo(this.userName,this.email,this.phonenumber,this.remark).then(res=>{
                    // console.log(res);
                    this.$toast(res.msg)
                    // console.log(this.userName)
                    this.$store.dispatch('login/getUserInfo')

                })
            }
    },
        created() {
            getusertInfo().then(res=>{
                // console.log(res);
                if(res.code ==0) {
                    this.userName = res.data.userName;
                    this.phonenumber = res.data.phonenumber;
                    this.email = res.data.email;
                    this.remark = res.data.remark;
                }else {
                    this.$toast("错误")
                }
            })
        }

    }
</script>

<style lang="less" scoped>

</style>